@import "shared";

// ----------------------------------------------------------------------------
// @private css3-feature-support variables must always include a list of five boolean values
// representing in order: -moz, -webkit, -o, -ms, -khtml
$multicolumn-support: -moz, -webkit, not -o, not -ms, not -khtml;

// ----------------------------------------------------------------------------
// Mixins

// Specify the shorthand `columns` property.
//
// Example:
//
//     @include columns(20em 2);
@mixin columns($width-and-count) {
  @include experimental(columns, $width-and-count, $multicolumn-support...);
}

// Specify the number of columns
@mixin column-count($count) {
  @include experimental(column-count, $count, $multicolumn-support...);
}

// Specify the gap between columns e.g. `20px`
@mixin column-gap($width) {
  @include experimental(column-gap, $width, $multicolumn-support...);
}

// Specify the width of columns e.g. `100px`
@mixin column-width($width) {
  @include experimental(column-width, $width, $multicolumn-support...);
}

// Specify how many columns an element should span across.
//
// * legal values are 1, all
@mixin column-span($columns) {
	@include experimental(column-span, $columns,
		-moz, -webkit, -o, -ms, not -khtml, official
	);
}

// Specify the width of the rule between columns e.g. `1px`
@mixin column-rule-width($width) {
  @include experimental(rule-width, $width, $multicolumn-support...);
}

// Specify the style of the rule between columns e.g. `dotted`.
// This works like border-style.
@mixin column-rule-style($style) {
  @include experimental(rule-style, unquote($style), $multicolumn-support...);
}

// Specify the color of the rule between columns e.g. `blue`.
// This works like border-color.
@mixin column-rule-color($color) {
  @include experimental(rule-color, $color, $multicolumn-support...);
}

// Mixin encompassing all column rule properties
// For example:
//
//     @include column-rule(1px, solid, #c00)
//
// Or the values can be space separated:
//
//     @include column-rule(1px solid #c00)
@mixin column-rule($width, $style: false, $color: false) {
  $full : -compass-space-list(compact($width, $style, $color));
  @include experimental(column-rule, $full, $multicolumn-support...);
}

// All-purpose mixin for setting column breaks.
//
// * legal values for $type : before, after, inside
// * legal values for '$value' are dependent on $type
//    * when $type = before, legal values are auto, always, avoid, left, right, page, column, avoid-page, avoid-column
//    * when $type = after, legal values are auto, always, avoid, left, right, page, column, avoid-page, avoid-column
//    * when $type = inside, legal values are auto, avoid, avoid-page, avoid-column
//
//  Examples:
//    h2.before {@include column-break(before, always);}
//    h2.after {@include column-break(after, always); }
//    h2.inside {@include column-break(inside); }
//
//  Which generates:
//  h2.before {
//    -webkit-column-break-before: always;
//    break-before: always;}
//
//  h2.after {
//    -webkit-column-break-after: always;
//    break-after: always; }
//
//  h2.inside {
//    -webkit-column-break-inside: auto;
//    break-inside: auto;}

@mixin column-break($type: before, $value: auto){
  // Webkit uses non-standard syntax
  @if $experimental-support-for-webkit {
    -webkit-column-break-#{$type}: $value;
  }

  // Official syntax
  break-#{$type}: $value;
}

// Mixin for setting break-before
//
// * legal values are auto, always, avoid, left, right, page, column, avoid-page, avoid-column
//
//  Example:
//    h2.before {@include break-before(always);}
//
//  Which generates:
//
//  h2.before {
//    -webkit-column-break-before: always;
//    break-before: always;}
@mixin break-before($value: auto){
  @include column-break(before, $value);
}

@mixin column-break-before($value: auto){
  @include column-break(before, $value);
  @warn '"column-break-before" has been deprecated in favor of the official syntax: "break-before".'
}

// Mixin for setting break-after
//
// * legal values are auto, always, avoid, left, right, page, column, avoid-page, avoid-column
//
//  Example:
//    h2.after {@include break-after(always); }
//
//  Which generates:
//
//  h2.after {
//    -webkit-column-break-after: always;
//    break-after: always; }
@mixin break-after($value: auto){
  @include column-break(after, $value);
}

@mixin column-break-after($value: auto){
  @include column-break(after, $value);
  @warn '"column-break-after" has been deprecated in favor of the official syntax: "break-after".'
}

// Mixin for setting break-inside
//
// * legal values are auto, avoid, avoid-page, avoid-column
//
//  Example:
//    h2.inside {@include break-inside();}
//
//  Which generates:
//
//  h2.inside {
//    -webkit-column-break-inside: auto;
//    break-inside: auto;}
@mixin break-inside($value: auto){
  @include column-break(inside, $value);
}

@mixin column-break-inside($value: auto){
  @include column-break(inside, $value);
  @warn '"column-break-inside" has been deprecated in favor of the official syntax: "break-inside".'
}

// Mixin for setting column-span
//
// * legal values: none, all
//
//  Example:
//    h2.span {@include column-span();}
@mixin column-span($span: all){
  @include experimental(column-span, unquote($span), $multicolumn-support...);
}

// Mixin for setting column-fill
//
// * legal values: auto, balance
//
//  Example:
//    h2.fill {@include column-fill();}
@mixin column-fill($fill: balance){
  @include experimental(column-fill, unquote($fill), $multicolumn-support...);
}
